package com.ds.home.database.manager;

import com.ds.common.cache.Cache;
import com.ds.common.query.Condition;
import com.ds.common.query.JLuceneIndex;
import com.ds.config.ListResultModel;
import com.ds.home.*;
import com.ds.home.database.vo.*;
import com.ds.home.query.HomeConditionKey;
import com.ds.home.query.IOTConditionKey;
import com.ds.iot.HomeException;
import com.ds.iot.enums.ZNodeZType;

import java.util.List;
import java.util.Set;

public interface EIDBManager extends java.io.Serializable {


    public ListResultModel<Set<String>> findPlace(Condition<HomeConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findArea(Condition<HomeConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findDevice(Condition<IOTConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findEndPoint(Condition<IOTConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findZNode(Condition<IOTConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findAlarm(Condition<HomeConditionKey,JLuceneIndex> condition);

    public ListResultModel<Set<String>> findScene(Condition<HomeConditionKey,JLuceneIndex> condition);


    /**
     * @param name
     * @param personId
     * @return @
     */
    public EIPlace createPlace(String name, String parentId, String personId);

    /**
     * @param place
     * @
     */
    public void updatePlace(EIPlace place);

    /**
     * @param area
     * @
     */
    public void updateArea(EIArea area);

    /**
     * @param name
     * @param placeId
     * @return @
     */
    public EIArea createArea(String name, String placeId);

    /**
     * @param areaId
     * @
     */
    void deleteAreaById(String areaId);

    /**
     * @param placeId
     * @
     */
    void deletePlaceById(String placeId);

    /**
     * @param areaId
     * @return @
     */
    public EIArea getAreaById(String areaId);

    /**
     * @param name
     * @param placeId
     * @return @
     */
    public EIArea getAreaByname(String name, String placeId);

    /**
     * @param placeId
     * @return @
     */
    public EIPlace getPlaceById(String placeId);

    /**
     * @param personId
     * @return @
     */
    public List<EIPlace> findPlaceByPersonId(String personId);

    /**
     * @param orgId
     * @return @
     */
    public List<EIPlace> findPlaceByOrgId(String orgId);



    /**
     * 获取所有门店
     *
     * @param placeId
     * @return
     */
    public List<EIPlace> getChildPlaces(String placeId);

    /**
     * 获取直接门店ID
     *
     * @param placeId
     * @return @
     */
    public Set<String> getChildPlaceIds(String placeId);

    /**
     * @return @
     */
    public List<EIPlace> findAllPersonPlace();

    /**
     * @return @
     */
    public List<EIPlace> findAllOrgPlace();

    /**
     * @param personId
     * @return @
     */
    public List<EIArea> getAreasByPersonId(String personId);
//
//
//    public List<EIPlace> findPlaceByName(String name, String parentId);

    /**

     * @param name
     * parentId
     * @param userId
     * @return @
     */
    public List<EIPlace> findPlaceByName(String name, String parentId,String userId);

    /**
     * @param alarmId
     * @return @
     */
    public EIAlarm getAlarmById(String alarmId);

    /**
     * @param alarm
     * @
     */
    public void updateAlarm(EIAlarm alarm);

    /**
     * @param alarmid
     * @
     */
    public void deleteAlarmById(String alarmid);

    /**
     * @param scene
     * @
     */
    public void updateScene(EIScene scene);

    /**
     * @param sceneId
     * @
     */
    public void deleteScene(String sceneId);

    /**
     * @param sceneId
     * @return @
     */
    public EIScene getSceneById(String sceneId);

    /**
     * @param no
     * @return @
     */
    public EISensortype getSensoTypeByNo(Integer no);

    public EISensortype getSensoTypeById(String sensortypeId);

    public List<EIAlarm> getAlarmsBySensorId(String sensorId);

    public List<EIScene> getScenesBySensorId(String sensorId);

    public EIAlarm creatAlarm(String sensorId);

    public EIScene creatScene(String sensorId);

    public void deleteZNodeById(String sensorId);


    public void updateZNode(EIZNode node, boolean indb);

    public EIZNode createRootZNode(String endpointid, String placeId, String createuiserid, ZNodeZType type);

    public EIZNode getZNodeById(String Id);

    public List<EIZNode> getAllChildZNode(String parentNodeId);

    public List<EIZNode> getZNodesByDeviceId(String deviceid);



    public EIZNode createChildZNode(String parentNodeId, String endPointId);

    /**
     * 根据设备串号获取设备
     *
     * @param serialno
     * @return
     */
    public EIDevice getDeviceBySerialno(String serialno);

    /**
     * 根据设备串号获取设备
     *
     * @param account
     * @return
     */
    public List<EIDevice> getDevicesByBindAccount(String account);

    /**
     * 根据MACADDRESS获取设备
     *
     * @param macaddress
     * @return
     */
    public EIDevice getDeviceByMacaddress(String macaddress);

    /**
     * 根据渠道获取设备
     *
     * @param channel
     * @return
     */
    public List<EIDevice> findDeviceByChannel(String channel);

    /**
     * 指定房间内的设备
     *
     * @param areaId
     * @return
     */
    public List<EIDevice> findDeviceByArea(String areaId);

    /**
     * 指定门店内的设备
     *
     * @param placeId
     * @return
     */
    public List<EIDevice> findDeviceByPlace(String placeId);

    /**
     * 根据ID获取设备
     *
     * @param deviceId
     * @return
     */
    public EIDevice getDeviceById(String deviceId);

    /**
     * 删除设备
     *
     * @param deviceId
     * @return
     */
    public void deleteDevice(String deviceId);

    /**
     * 根据deviceId获取EP信息
     *
     * @param deviceId
     * @return
     */
    public List<EIDeviceEndPoint> getEndPointsByDeviceId(String deviceId);

    /**
     * 根据EPieee获取EP信息
     *
     * @param serialno
     * @return DBDeviceEndPoint
     */
    public EIDeviceEndPoint getEPBySerialno(String serialno);

    /**
     * 更新设备信息
     *
     * @param device
     */
    public void updateDevice(EIDevice device);

    public void updateDevice(EIDevice device, boolean indb);

    public void removeChildDevice(String bindingAccount, String chileDeviceId);

    /**
     * 新增设备信息
     */
    public EISensortype createSensorType();

    /**
     * 新增设备信息
     */
    public EIDevice createDevice(String serialno, String macaddress, Integer devicetype, String factory, String bindingAccount);

    /**
     * 新增设备信息
     */
    public EIDevice createRootDevice(String deviceId, String serialno, String macaddress, String factory, String version) throws HomeException;

    /**
     * 获取应用节点信息
     *
     * @param endPointId
     * @return DBDeviceEndPoint
     */
    public EIDeviceEndPoint getEndPoindById(String endPointId);

    /**
     * 更新应用节点信息
     *
     * @param device
     * @return
     */
    public void updateEndPoint(EIDeviceEndPoint device);

    public void updateEndPoint(EIDeviceEndPoint device, boolean indb);

    /**
     * 应用节点信息
     *
     * @return
     */
    public EIDeviceEndPoint createEndPoint(String deviceId, String ieeeAddress, String ep, Integer sensorType, String name);

    /**
     * 删除节点信息
     *
     * @param endPoindId
     */
    public void deleteEndPoint(String endPoindId);

    public List<EIArea> getAreasByPlaceId(String placeid);

    public List<EIZNode> getZNodesByEndPointId(String endPointId);

    public List<EIZNode> findZNodesByCreateId(String userId);

    public List<EISensortype> getSensorTypeByDeivceId(String deviceid);

    public Cache<String, AreaVO> getAreaCache();

    public Cache<String, PlaceVO> getPlaceCache();

    public Cache<String, SensortypeVO> getSensorTypeNoCache();

    public Cache<String, SensortypeVO> getSensorTypeIdCache();

    public Cache<String, AlarmVO> getAlarmCache();

    public Cache<String, SceneVO> getSceneCache();

    public Cache<String, DeviceVO> getDeviceCache();

    public Cache<String, String> getDeviceSerialnoCache();

    public Cache<String, DeviceEndPointVO> getEndPointCache();

    public Cache<String, String> getEndPointSerialnoCache();

    public Cache<String, String> getDevicemacadressCache();

    public Cache<String, String> getAllEPIdCache();

    public Cache<String, String> getAllChildIdCache();

    public Cache<String, ZNodeVO> getZnodeCache();

    public Cache<String, String> getCurrValueCache();

    public Cache<String, String> getAllZNodeIdCache();

    public Cache<String, String> getPlaceRefChildIdCache();

    public Cache<String, String> getAllAreaIdCache();

    public Cache<String, String> getZNodeRefZNodeCache();

    public Cache<String, String> getZNodeRefAlarmCache();

    public Cache<String, String> getAllSceneIdCache();

    public Set<String> getAreaIdsByPlaceId(String placeid);

    Set<String> findGWDevicesByFactory(String factoryName);

    EISensortype updateSensorType(EISensortype sensortype)throws HomeException ;

    void deleteSensorType(Integer typeno)throws HomeException ;
}
